Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

295
Views
How to debug a "Cannot find module" error in Javascript? MODULE_NOT_FOUND

I have a Typescript project whose tsconfig.json file currently looks like this:

{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "target": "es2020",
    "baseUrl": "src",
    "outDir": "dist",
    "declaration": false,
    "sourceMap": true,
    "esModuleInterop": true,
    "newLine": "lf",
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "strictNullChecks": true,
    "importsNotUsedAsValues": "error",
    "isolatedModules": true,
    "skipLibCheck": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noUncheckedIndexedAccess": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "preserveConstEnums": true
  },
  "include": ["src"]
}

When I build my project with tsc no problems arise. But when I run it with node dist/server/index.js I get errors like Cannot find module 'server/foo/bar' MODULE_NOT_FOUND.

What tools do developers have to try to debug this?

TypeScript could find the module during transpilation, otherwise it would have failed. Why can't JavaScript find it then?

How can I know where it tried to look for the module? Or any other information that could help the developer figure out how to fix this.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!